#include "vcd-wire.h"
#include "vcd-node.h"
#include "vcd-wifi.h"
#include "vcd-setting-network.h"
#include "../../../vcd-common-api/vcd-common.h"


static
void change_pic_network(GtkNotebook *notebook, GtkWidget *page, guint page_num)
{
    //GtkWidget *labelcurrent = gtk_notebook_get_tab_label(notebook, page);
    switch (page_num)
    {
    case 0: //gtk_entry_set_text(GTK_ENTRY(entryNode), get_txt_node());//设置上一次连接的节点
        break;
    case 1: set_network_information();
        break;
    case 2: gdk_threads_add_idle((GSourceFunc)add_items, NULL);
        break;
    }
}

GtkWidget* get_setting_network_notebook(void)
{
    GtkWidget *notebook_network;
    notebook_network = gtk_notebook_new();
    gtk_notebook_set_show_border((GtkNotebook *)notebook_network, FALSE);

    GtkWidget *fix_network_server_ip = get_sys_loginway_fix();
    GtkWidget *fix_network_wired     = get_sys_wire_info_fix();

    GtkWidget *notelabel_server_ip = gtk_label_new("\n节点\n");
    #ifdef __linux__
    GtkWidget *notelabel_wired     = gtk_label_new("\n有线\n");
    #endif

    gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook_network), GTK_POS_TOP);//设置notebook标题栏的位置

    gtk_notebook_append_page(GTK_NOTEBOOK(notebook_network), fix_network_server_ip, notelabel_server_ip);
    #ifdef __linux__
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook_network), fix_network_wired, notelabel_wired);

    if (get_whether_have_wifi_model()) {
        GtkWidget *fix_network_wifi = get_sys_wifi_info_fix();
        GtkWidget *notelabel_wifi = gtk_label_new("\n无线\n");
        gtk_notebook_append_page(GTK_NOTEBOOK(notebook_network), fix_network_wifi, notelabel_wifi);
    }
    #endif
    gtk_notebook_set_show_border((GtkNotebook *)notebook_network, FALSE);

    g_signal_connect(G_OBJECT(notebook_network), "switch-page", G_CALLBACK(change_pic_network), NULL);

    set_css(notebook_network, "header{background:rgb(245,245,245);"
            "border-bottom:0px solid rgb(230,230,230)}");
    set_css(notebook_network, "notebook{background-color:rgb(255,255,255);"
            "border-bottom:none;"
            "border-radius:0px}");

    return notebook_network;
}
